﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OlapProject
{
    static class FreeAgentHouseParseUtil
    {
        static Dictionary<String, String> helperMap = new Dictionary<String, String>();
        static string[] elements;
        static string[] singleElement;

        static public void prepareString(string text)
        {
            helperMap.Clear();          
            elements = text.Split('\n');        
            foreach (String line in elements)
            {
                if (line.IndexOf(":") > 0)
                {
                    
                    singleElement = line.Split(':');
                    helperMap.Add(singleElement[0].Trim(), singleElement[1].ToLower().Trim());
                }
            }
        }

        static public string getString(string key, string defaultValue = "")
        {
            string result = defaultValue;
            if(helperMap.ContainsKey(key))
            {
                result = helperMap[key];
            }
            return result;
        }

        static public int getInt(string key, int defaultValue = 0)
        {
            string stringResult = getString(key, string.Empty);
            return stringResult == string.Empty ? defaultValue : int.Parse(stringResult);
        }
    }
}
